<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      //反转数组
      function reverse(arr) {
        if (arr instanceof Array) {
          var newArr = [];
          for (i = arr.length - 1; i >= 0; i--) {
            arr1[newArr.length] = arr[i];
          }
          return newArr;
        } else {
          return "你输入的并不是一个数组";
        }
      }
      //检测是否为数组
      //1. instanceof 运算符
      var arr = [];
      var obj = {};
      console.log(arr instanceof Array);
      console.log(obj instanceof Array);
      console.log(reverse(1, 2, 3));
      console.log();
      //Array.isArray(参数);
      console.log(Array.isArray(arr));
    </script>
  </head>
  <body></body>
</html>
